#define _WIN32_WINNT  0x0500// enable the new API 
#include<windows.h>
#include <stdio.h>
#include <process.h>
#include "resource.h"
#pragma comment (linker,"/SUBSYSTEM:WINDOWS")
HANDLE hTimer;
LARGE_INTEGER li;
static int g_Flag  =0;
int WINAPI Dlg_Proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{   
	static HDC hdc;
	static HDC hdcMem;
	static HBITMAP hBitmap;
	static int cxScreen,cyScreen,cxDlg,cyDlg;
	static BITMAP bitmap;
    HINSTANCE hInst2=LoadLibrary("User32.DLL");
	PAINTSTRUCT ps;
	switch (uMsg)
	{
	case WM_NCHITTEST:
		return HTCLIENT;
	case WM_PAINT: 
 		break;;
	case WM_INITDIALOG:
		RECT rt;
		cxScreen=GetSystemMetrics(SM_CXSCREEN);
		cyScreen=GetSystemMetrics(SM_CYSCREEN);
        GetWindowRect(hwnd,&rt);
		cxDlg=rt.right;
		cyDlg=rt.bottom;
		SetWindowPos(hwnd,HWND_TOPMOST,(cxScreen-cxDlg)/2,(cyScreen-cyDlg)/2,
				cxDlg,cyDlg,SWP_SHOWWINDOW);
		SetWindowLong(hwnd,GWL_EXSTYLE,
		            GetWindowLong(hwnd,GWL_EXSTYLE)^0x80000);
		SetLayeredWindowAttributes(hwnd,0,200,2);
		if(g_Flag == 0)
		{
			SetTimer(hwnd,ID_TIMER,1000,NULL);
			g_Flag =1;
		}
		else
			SetTimer(hwnd,ID_TIMER,1000*60*10,NULL);		
		break;
	case WM_TIMER:
		EndDialog(hwnd,NULL);
		break;
	}
   return(FALSE);
}
unsigned int __stdcall Tell(PVOID pvParam)
{
	while(1)
	{
		WaitForSingleObject(hTimer,INFINITE);
		DialogBox(NULL,MAKEINTRESOURCE(IDD_DIALOG1),NULL,Dlg_Proc);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int)
{
	unsigned threadID;
	hTimer = CreateWaitableTimer(NULL,FALSE,"ZHUBICEN");
	if(GetLastError() == ERROR_ALREADY_EXISTS)
	{
		MessageBox(NULL,TEXT("The other instance is runing!"),TEXT("Waring!"),MB_OK);
		return 1;
	}
	const int nTimerUnitsPerSecond =10000000;
	li.QuadPart = -(5*nTimerUnitsPerSecond);
	SetWaitableTimer(hTimer,&li,60*60*1000,NULL,NULL,FALSE);
	HANDLE hThread = (HANDLE)_beginthreadex(NULL,0,&Tell,NULL,0,NULL);
	WaitForSingleObject( hThread, INFINITE );
	return 0;
}
